
// 引入
import Vue from "vue";
import VueRouter from "vue-router";

// 使用
Vue.use(VueRouter)

// 获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
const originalReplace = VueRouter.prototype.replace
// 修改原型对象中的push方法(捕获报错)
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location,()=>{},()=>{})
}
VueRouter.prototype.replace = function replace(location) {
    return originalReplace.call(this, location,()=>{},()=>{})
}

// 引入路由组件
import Home from "@/pages/home"
import Search from "@/pages/search"
import Login from "@/pages/login"
import Register from "@/pages/register"
// 配置路由
export default new VueRouter({
    routes:[
        {
            path:"/home",
            component:Home,
            meta:{
                showFooter:true
            }
        },{
            name:"search",
            path:"/search/:keyword",
            component:Search,
            meta:{
                showFooter:true
            }
        },{
            path:"/login",
            component:Login,
            meta:{
                showFooter:false
            }
        },{
            path:"/register",
            component:Register,
            meta:{
                showFooter:false
            }
        },{
            path:"/",
            redirect:"/home"
        }
    ]
})

